package initialize

import (
	"github.com/smartwalle/alipay/v3"

	"mxshop-api/order-web/global"
)

func AlipayInit() (*alipay.Client, error) {
	conf := global.ServerConfig.AlipayConfig
	client, err := alipay.New(conf.AppID, conf.AppPrivateKey, conf.IsProduction)
	if err != nil {
		return nil, err
	}

	err = client.LoadAliPayPublicKey(conf.AlipayPublicKey)
	if err != nil {
		return nil, err
	}

	return client, nil
}
